/** 
 *  @file       led.c
 *  @brief      LED驱动程序     开发板的P0端口连接8个LED
 *  @author     Z B T   
 *  @version    V0.1
 *  @date       2015-10
 */
 
#include "led.h"
#include "delay.h"
#include "config.h"

#define LED_PORT    P0        

/**
 *  LED闪烁
 *  @param None
 *  @return None
 */
void led_flash(enum LED led_value, unsigned int t_ms)
{
    LED_PORT = 0x00;
    
    led_on(led_value);
    delay_ms(t_ms);
    led_off(led_value);
    delay_ms(t_ms);
}
/**
 *  8个led形成流水灯
 *  @param None
 *  @return None
 */
void led_loop(void)
{
    unsigned char i;
    unsigned char led_value = LED_0;
    
    LED_PORT = 0x00;

    for (i = 0; i < 8; i++)
    {
        led_on((led_value << i));
        delay_ms(500);
    }
}

/**
 *  点亮LED
 *  @param [in] led_value
 *  @return None
 */
void led_on(enum LED led_value)
{
    LED_PORT |= led_value;
}


/**
 *  熄灭LED
 *  @param [in] led_value
 *  @return None
 */
void led_off(enum LED led_value)
{
    LED_PORT &= ~led_value;
}